/**
 * Copyright 2004 - 2007 Blue Bamboo International Inc. 
 *           All rights reserved.
 *
 *
 * Blue Bamboo PROPRIETARY/CONFIDENTIAL.
 *
 */

package com.bluebamboo.bluetools.pingpang.connection;

import java.util.ArrayList;

import org.apache.mina.core.service.IoHandler;

import com.bluebamboo.bluetools.pingpang.bean.ConnectionBean;

/**
 * DOCME
 * 
 * @author tanxuqing
 * @date Sep 13, 2009
 * @since
 */
public abstract class AbstractConnectionHandler<T extends ConnectionBean> implements IConnectionHandler {

	protected T connectionBean;
	protected IoHandler ioHandler;
	private Status status;

	/**
	 * @param connectonBean
	 */
	public AbstractConnectionHandler(T connectonBean) {
		this.connectionBean = connectonBean;
	}

	public T getConnectionBean() {
		return connectionBean;
	}

	public void connect() throws Exception {
		status = Status.CONNECTED;
	}

	public void disconnect() throws Exception {
		status = Status.DISCONNECTED;
	}

	public Status getStatus() {
		return status;
	}

	/**
	 * set the default <code>IoHandler</code>, maybe we need provide a way to add filters?
	 * 
	 * @param ioHandler
	 */
	public void setIoHandler(IoHandler ioHandler) {
		this.ioHandler = ioHandler;
	}

	protected IoHandler getIoHandler() {
		return this.ioHandler;
	}
}
